Skip to content

Fix flicker in SSR when using dark mode #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
Merged

Fix flicker in SSR when using dark mode #36

merged 2 commits into from
Mar 31, 2025

Conversation

gfrn
Copy link
Collaborator

@gfrn gfrn commented Mar 5, 2025

Since the previous mechanism for theming the application depended on client-side logic, it was not rendering correctly in a SSR environment (there was a quick flicker of light mode, then the application settled into dark mode).

This fixes this issue by utilising CSS variables, and MUI's own best practices for dark/light mode theming in SSR/SPA contexts.

The navbar logo has also had its logic modified, so it is independent of Javascript, and instead, magically renders the correct one based on user preferences for dark/light mode (even if the page is rendered server side).

@gfrn gfrn requested a review from akademy March 5, 2025 09:35
@gfrn gfrn self-assigned this Mar 5, 2025
Copy link
Member

@akademy akademy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I thought this "flashing" might bite us at some point. Thanks for looking at this.

I've add a change and a question to a review. (Also, there's some tedious formatting to fix - can you believe GitHub automatically highlights them in a review. Highly annoying!)

@akademy
Copy link
Member

akademy commented Mar 25, 2025

Looks good. Feel free to merge in.

@akademy akademy merged commit 877d2fa into main Mar 31, 2025
1 check passed
@akademy akademy deleted the dark-mode-ssr branch April 8, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants